package o;

import android.app.PendingIntent;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.c;
import androidx.core.app.NotificationCompat.d;
import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.ewm.e;

public class dkk {
    private static float ˊ = SizeModifier.STABLE_STATE_SCALE;
    private static Bitmap ˎ = null;
    private Context ˋ;
    private dko ॱ;

    public dkk(Context context, dko o_dko) {
        this.ˋ = context;
        this.ॱ = o_dko;
    }

    public static dkk ˊ(Context context, dko o_dko) {
        dkk o_dkk = new dkk(context, o_dko);
        o_dkk.ˎ();
        return o_dkk;
    }

    public static synchronized void ˏ() {
        synchronized (dkk.class) {
            ˎ = null;
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static synchronized float ˊ() {
        /*
        r2 = o.dkk.class;
        monitor-enter(r2);
        r0 = ˊ;	 Catch:{ all -> 0x0046 }
        r1 = -1082130432; // 0xffffffffbf800000 float:-1.0 double:NaN;
        r0 = (r0 > r1 ? 1 : (r0 == r1 ? 0 : -1));
        if (r0 != 0) goto L_0x0038;
    L_0x000b:
        r0 = o.doq.ॱ();	 Catch:{ all -> 0x0046 }
        r0 = r0.ˋ();	 Catch:{ all -> 0x0046 }
        r1 = 48;
        r0 = o.epv.ˋ(r0, r1);	 Catch:{ all -> 0x0046 }
        r1 = (float) r0;
        r0 = o.doq.ॱ();	 Catch:{ NotFoundException -> 0x003c }
        r0 = r0.ˋ();	 Catch:{ NotFoundException -> 0x003c }
        r0 = r0.getResources();	 Catch:{ NotFoundException -> 0x003c }
        r3 = 17104901; // 0x1050005 float:2.4428256E-38 double:8.450944E-317;
        r0 = r0.getDimension(r3);	 Catch:{ NotFoundException -> 0x003c }
        r3 = 0;
        r3 = (r0 > r3 ? 1 : (r0 == r3 ? 0 : -1));
        if (r3 <= 0) goto L_0x0044;
    L_0x0032:
        r3 = (r0 > r1 ? 1 : (r0 == r1 ? 0 : -1));
        if (r3 >= 0) goto L_0x0044;
    L_0x0036:
        ˊ = r0;	 Catch:{ all -> 0x0046 }
    L_0x0038:
        r0 = ˊ;	 Catch:{ all -> 0x0046 }
        monitor-exit(r2);
        return r0;
    L_0x003c:
        r0 = move-exception;
        r0 = "BaseNotification";
        r3 = "get notification_large_icon_width failed!!!!!!NotFoundException";
        o.dna.ˎ(r0, r3);	 Catch:{ all -> 0x0046 }
    L_0x0044:
        r0 = r1;
        goto L_0x0036;
    L_0x0046:
        r0 = move-exception;
        monitor-exit(r2);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.dkk.ˊ():float");
    }

    public static synchronized Bitmap ॱ(Context context) {
        Bitmap bitmap;
        synchronized (dkk.class) {
            if (ˎ == null && context != null) {
                float ˊ = ˊ();
                try {
                    Drawable applicationIcon = context.getPackageManager().getApplicationIcon(context.getPackageName());
                    Matrix matrix = new Matrix();
                    float intrinsicWidth = ˊ / ((float) applicationIcon.getIntrinsicWidth());
                    matrix.postScale(intrinsicWidth, intrinsicWidth);
                    ˎ = Bitmap.createBitmap((int) ˊ, (int) ˊ, applicationIcon.getOpacity() != -1 ? Config.ARGB_8888 : Config.RGB_565);
                    Canvas canvas = new Canvas(ˎ);
                    canvas.setMatrix(matrix);
                    applicationIcon.setBounds(0, 0, applicationIcon.getIntrinsicWidth(), applicationIcon.getIntrinsicHeight());
                    applicationIcon.draw(canvas);
                } catch (NameNotFoundException e) {
                    Logger.ˋ("BaseNotification", "icon can not get:" + e.toString());
                } catch (OutOfMemoryError e2) {
                    Logger.ˋ("BaseNotification", "icon can not get:");
                } catch (IllegalArgumentException e3) {
                    Logger.ˋ("BaseNotification", "icon can not get : " + e3.toString());
                }
            }
            bitmap = ˎ;
        }
        return bitmap;
    }

    public static void ˊ(final d dVar, final int i, String str, final String str2) {
        if (dVar == null) {
            Logger.ˎ("BaseNotification", "loadLargeIconAndNotify: builder is null");
        } else if (str == null || str2 == null) {
            Logger.ˎ("BaseNotification", "loadLargeIconAndNotify: param is null");
            ˏ(ॱ(ContentManager.getInstant().getContext()), dVar, i);
        } else {
            final Context ˋ = ContentManager.getInstant().getContext();
            eqx.ॱ(ˋ, str, new eqz() {
                public void ॱ(Bitmap bitmap) {
                    if (bitmap != null) {
                        dkk.ˏ(bitmap, dVar, i);
                    } else {
                        ˏ();
                    }
                }

                private void ˏ() {
                    new Thread(this, "onImageLoadFailed") {
                        final /* synthetic */ AnonymousClass2 ˎ;

                        public void run() {
                            try {
                                Bitmap ˎ = erm.ˏ().ˎ(str2, false);
                                if (ˎ == null) {
                                    ˎ = dkk.ॱ(ˋ);
                                }
                                dkk.ˏ(ˎ, dVar, i);
                            } catch (OutOfMemoryError e) {
                                Logger.e("BaseNotification", "getNotifyLargeIcon(Context context,String url,String packagename ) ");
                            }
                        }
                    }.start();
                }
            });
        }
    }

    private static void ˏ(Bitmap bitmap, d dVar, int i) {
        float ˊ = ˊ();
        dVar.ˎ(eqx.ˏ(bitmap, (double) ˊ, (double) ˊ));
        cei.ॱ(ContentManager.getInstant().getContext(), "BaseNotification", i, dVar);
    }

    public void ˎ() {
        d ˊ = ˊ(false);
        if (ˊ != null) {
            cei.ॱ(this.ˋ, "BaseNotification", this.ॱ.ʼ(), ˊ);
        }
    }

    public void ˋ() {
        d ˊ = ˊ(true);
        if (ˊ != null) {
            cei.ॱ(this.ˋ, "BaseNotification", this.ॱ.ʼ(), ˊ);
        }
    }

    private d ˊ(boolean z) {
        Bitmap bitmap = null;
        if (this.ॱ == null || this.ˋ == null) {
            return null;
        }
        d dVar = new d(this.ˋ);
        dVar.ˏ(this.ॱ.ॱ());
        dVar.ˊ(this.ॱ.ʻ());
        dVar.ˏ(this.ॱ.ˎ());
        dVar.ˊ(this.ॱ.ˏ());
        if (this.ॱ.ˋ() != null) {
            bitmap = this.ॱ.ˋ();
            if (bitmap != null) {
                float ˊ = ˊ();
                bitmap = eqx.ˏ(bitmap, (double) ˊ, (double) ˊ);
            }
        }
        if (bitmap != null) {
            dVar.ˎ(bitmap);
        }
        if (this.ॱ.ॱॱ() != 0) {
            dVar.ˊ(this.ॱ.ॱॱ());
        } else {
            dVar.ˊ(e.ॱ);
        }
        if (this.ॱ.ᐝ() != null) {
            bitmap = this.ॱ.ᐝ();
            c eVar = new NotificationCompat.e();
            eVar.ˋ(bitmap);
            dVar.ˋ(eVar);
        }
        if (this.ॱ.ˊ() == null) {
            return dVar;
        }
        if (z) {
            dVar.ˎ(PendingIntent.getBroadcast(this.ˋ, this.ॱ.ʼ(), this.ॱ.ˊ(), HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR));
            return dVar;
        }
        dVar.ˎ(PendingIntent.getActivity(this.ˋ, this.ॱ.ʼ(), this.ॱ.ˊ(), 268435456));
        return dVar;
    }

    public void ॱ() {
        cei.ˋ(ContentManager.getInstant().getContext(), "BaseNotification", this.ॱ.ʼ());
    }
}
